package com.pmsystem.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pmsystem.dao.FixMapper;
import com.pmsystem.pojo.Fix;
import com.pmsystem.pojo.FixExample;
import com.pmsystem.pojo.FixExample.Criteria;
import com.pmsystem.util.BeanUtil;
@Service
public class FixService {

	@Autowired
	private FixMapper fixMapper;
	
	/**
	 * 
	 * <p>Title: addFix</p >  
	 * <p>Description: 添加维修项</p >  
	 * @author 泽强
	 * @param fix
	 * @return
	 */
	public boolean addFix(Fix fix) {	
		int flag = fixMapper.insertSelective(fix);
		return flag==1?true:false;		
	}

	/**
	 * 
	 * <p>Title: update</p >  
	 * <p>Description: 更新维修账单</p >  
	 * @author 泽强
	 * @param fix
	 * @return
	 */
	public boolean update(Fix fix) {	
		int flag=fixMapper.updateByPrimaryKeySelective(fix);
		return flag==1?true:false;
	}

	/**
	 * 
	 * <p>Title: findAllFix</p >  
	 * <p>Description: 分页查询账单</p >  
	 * @author 泽强
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	public List<Fix> findAllFix(Integer pageNo, Integer pageSize) {
		int start = (pageNo-1)*pageSize;
		return fixMapper.findAllFix(start,pageSize);
	}
	
	/**
	 * 
	 * <p>Title: findFix</p >  
	 * <p>Description: 按一定条件查找维修单，注意SQL语句</p >  
	 * @author 泽强
	 * @param map
	 * @return
	 */
	public List<Fix> findFix(Map<String,Object> map) {
		Integer pageNo = (Integer) map.get("pageNo");
		Integer pageSize = (Integer) map.get("pageSize");
		if(pageNo!=null&&pageSize!=null) {
			int start = (pageNo - 1) * pageSize;
			map.put("start", start);
		}
		List<Fix> list = fixMapper.findFix(BeanUtil.mapToMapWithoutNull(map));
		return list;
	}

}
